#!/usr/bin/env python

import unittest

from numpy import *
from Numeric import array

from OpenGLDataView import OpenGLDataView

class OpenGLDataViewTest(unittest.TestCase):
  """Tests for OpenGLDataView"""
  
  def setUp(self):
    # Set up data points
    self.data = array([
      [ 0.0,  0.0,  0.0],
      [10.0,  0.0,  0.0],
      [ 0.0, 10.0,  0.0],
      [ 0.0,  0.0, 10.0],
      [10.0, 10.0,  0.0],
      [ 0.0, 10.0, 10.0],
      [10.0,  0.0, 10.0],
      [10.0, 10.0, 10.0]])
    
    self.dataHighDim = concatenate((self.data, zeros((self.data.shape[0], 3))), 1)
    
    self.dataLowDim  = self.data[:, 1:2]
    
    self.colors = array([
      [0.0, 0.0, 0.0],
      [1.0, 0.0, 0.0],
      [0.0, 1.0, 0.0],
      [0.0, 0.0, 1.0],
      [1.0, 1.0, 0.0],
      [0.0, 1.0, 1.0],
      [1.0, 0.0, 1.0],
      [1.0, 1.0, 1.0]])
  
  def testInitWithoutColors(self):
    foo = OpenGLDataView(self.data)
    
    self.assertEqual(foo.n, self.data.shape[0])
  
  def testInitWithColors(self):
    foo = OpenGLDataView(self.data, colors=self.colors)
    
    self.assertEqual(foo.n, self.data.shape[0])
  
  def testInitInvalidColors(self):
    self.assertRaises(IndexError, OpenGLDataView, self.data, colors=self.colors[0:1, 0:1])
  
  def testInitHighDimension(self):
    foo = OpenGLDataView(self.dataHighDim, colors=self.colors)
    
    self.assertEqual(foo.dim, self.dataHighDim.shape[1])
  
  def testInitLowDimension(self):
    foo = OpenGLDataView(self.dataLowDim, colors=self.colors)
    
    self.assertEqual(foo.dim, self.dataLowDim.shape[1])
  
  # TODO : Add tests for neighbours parameter
  # TODO : Add tests for knn parameter
  # TODO : Add tests for height, width, fullscreen parameters
  # TODO : Add tests for 

if __name__ == '__main__':
  unittest.main()
